﻿function applyRangeRefinement(managedProperty, sliderInstance) {
    var currentUrl = window.location.href;
    var urlChunks = currentUrl.split("&");
    var values = sliderInstance.getCurrentRange();
    var minValue = null;
    var maxValue = null;

    if (values != null) {
        minValue = values.left;
        maxValue = values.right;
    }

    var queryAppend = "";
    if (minValue != null && maxValue != null) {
        queryAppend = queryAppend + managedProperty + ":";

        if (minValue != null) { queryAppend = queryAppend + minValue; }
        queryAppend = queryAppend + "..";
        if (maxValue != null) { queryAppend = queryAppend + maxValue; }
    } 

    aparam = RemoveRefinerFromFilterUrl(location.href, managedProperty);
    if (aparam == -1) aparam = location.href;
    aparam = GetFilterUrl(aparam, queryAppend);
    if (aparam != -1) {
        DisableCheckboxes();
        location.href = aparam;
    }
}

function resetRangeRefinement(managedProperty) {
    aparam = linkAllSelection(managedProperty);
    if (aparam != -1) {
        DisableCheckboxes();
        location.href = aparam;
    }
}